package com.yupi.longojbackendjudgeservice.judge;


import com.yupi.longojbackendjudgeservice.judge.strategy.DefaultJudgeStrategy;
import com.yupi.longojbackendjudgeservice.judge.strategy.JavaLanguageJudgeStrategy;
import com.yupi.longojbackendjudgeservice.judge.strategy.JudgeContext;
import com.yupi.longojbackendjudgeservice.judge.strategy.JudgeStrategy;
import com.yupi.longojbackendmodel.codesandbox.JudgeInfo;
import com.yupi.longojbackendmodel.entity.QuestionSubmit;
import org.springframework.stereotype.Service;


@Service
/**
 * 判题管理（简化调用）
 */
public class JudgeManager {

    /**
     * 执行判题
     */

    JudgeInfo doJudge(JudgeContext judgeContext){
        QuestionSubmit questionSubmit = judgeContext.getQuestionSubmit();
        String language = questionSubmit.getLanguage();
        JudgeStrategy judgeStrategy=new DefaultJudgeStrategy();
        if ("java".equals(language)) {
            judgeStrategy=new JavaLanguageJudgeStrategy();
        }
        return judgeStrategy.doJudge(judgeContext);
    }

}
